import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileInputStream;
import java.io.IOException;

public class Teacher {
    String[] user = new String[3];
    String[] password = new String[3];
    XSSFWorkbook workbook;

    Teacher() {
        try {
            workbook = new XSSFWorkbook(new FileInputStream("F:\\java\\work\\JavaHomeWork\\src\\stu.xlsx"));
            //当密码为数字时，超过6位时，会出现小数点，读取时会出现小数点或变为e结尾
            //password[1] = String.valueOf(workbook.getSheetAt(2).getRow(i).getCell(2)).substring(0,String.valueOf(workbook.getSheetAt(2).getRow(i).getCell(2)).lastIndexOf("."));
            for(int i = 1; i < 4;i++){
                user[i-1] = workbook.getSheetAt(2).getRow(i).getCell(1) + "";
                password[i-1] = workbook.getSheetAt(2).getRow(i).getCell(2) + "";
            }
        } catch (IOException e) {
            System.out.println("读取错误！");
        }

    }
}


